/*
 * IMatrixWriter.cs
 *
 * Interface for writing matrix to a file or stream
 *
 * Copyright (c) 2005, dnAnalytics. All rights reserved.
 */
using System;
using System.IO;
using dnAnalytics.LinearAlgebra;

namespace dnAnalytics.LinearAlgebra.IO
{
    /// <summary>
    /// Interface for writing an <see cref="Matrix"/> to a file or stream.
    /// </summary>
    public interface IMatrixWriter
    {
        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given file. If the file already exists, 
        /// the file will be overwritten.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="file">The file to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="file"/> is null.</exception>
        void WriteMatrix(Matrix matrix, string file);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given file. If the file already exists, 
        /// the file will be overwritten.
        /// </summary>
        /// <param name="matrix">the matrix to write.</param>
        /// <param name="file">The file to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="file"/> is null.</exception>
        void WriteMatrix(Matrix matrix, string file, string format);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given stream.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="stream">The <see cref="Stream"/> to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="stream"/> is null.</exception>
        void WriteMatrix(Matrix matrix, Stream stream);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given stream.
        /// </summary>
        /// <param name="matrix">The <see cref="TextWriter"/> to write.</param>
        /// <param name="stream">The <see cref="Stream"/> to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="stream"/> is null.</exception>
        void WriteMatrix(Matrix matrix, Stream stream, string format);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given <b>TextWriter</b>.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="writer">The <see cref="TextWriter"/> to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="writer"/> is null.</exception>
        void WriteMatrix(Matrix matrix, TextWriter writer);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given <b>TextWriter</b>.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="writer">The <see cref="TextWriter"/> to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="writer"/> is null.</exception>
        void WriteMatrix(Matrix matrix, TextWriter writer, string format);
    }
}
